import  time
from selenium import  webdriver
from selenium.webdriver.common.by import By
class BrowserOperation:
    def __init__(self):
        self.driver=webdriver.Chrome()
        self.driver.get("https://www.baidu.com")

    def quit(self,seconds=2):
        time.sleep(seconds)
        self.driver.quit()


    # 浏览器窗口大小调整
    def window_size(self):
        self.driver.set_window_size(480,800)
        time.sleep(3)
        #最大化
        self.driver.maximize_window()

    # 页面的前进后退和刷新
    def forwaed_back(self):
        #后退
       self.driver.back()
       self.driver.forward()

    def close(self):
        self.driver.find_element(By.LINK_TEXT, "新闻").click()
        time.sleep(2)
        self.driver.close()

if __name__ == '__main__':
    oper = BrowserOperation()
    # oper.window_size()
    # oper.forward_back()
    oper.close()
    oper.quit()